package com.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

/**
 * @Author 咕唧
 * @Date 2022/6/27 21:40
 * @Version 1.0
 */
@SpringBootApplication
@EnableZuulProxy
public class ZuulStartApp {
    public static void main(String[] args) {
        SpringApplication.run(ZuulStartApp.class, args);
    }

    /**
     * 我们的服务的名字是 任意内容-v任意内容的格式, 会把访问地址转换成 /v任意内容/任意内容
     * 为了同时布置多个版本，防止接口冲突
     *
     * @return
     */
    @Bean
    public PatternServiceRouteMapper serviceRouteMapper() {
        return new PatternServiceRouteMapper(
                "(?<name>^.+)-(?<version>v.+$)",
                "${version}/${name}");
    }
}
